<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Emulated TLS (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Emulated TLS (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Emulated TLS (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Target-Macros.html" rel="up" title="Target Macros">
<link href="MIPS-Coprocessors.html" rel="next" title="MIPS Coprocessors">
<link href="Target-Attributes.html" rel="prev" title="Target Attributes">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>


</head>

<body lang="en">
<div class="section-level-extent" id="Emulated-TLS">
<div class="nav-panel">
<p>
Next: <a href="MIPS-Coprocessors.html" accesskey="n" rel="next">Defining coprocessor specifics for MIPS targets.</a>, Previous: <a href="Target-Attributes.html" accesskey="p" rel="prev">Defining target-specific uses of <code class="code">__attribute__</code></a>, Up: <a href="Target-Macros.html" accesskey="u" rel="up">Target Description Macros and Functions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Emulating-TLS"><span>18.25 Emulating TLS<a class="copiable-link" href="#Emulating-TLS"> &para;</a></span></h3>
<a class="index-entry-id" id="index-Emulated-TLS"></a>

<p>For targets whose psABI does not provide Thread Local Storage via
specific relocations and instruction sequences, an emulation layer is
used.  A set of target hooks allows this emulation layer to be
configured for the requirements of a particular target.  For instance
the psABI may in fact specify TLS support in terms of an emulation
layer.
</p>
<p>The emulation layer works by creating a control object for every TLS
object.  To access the TLS object, a lookup function is provided
which, when given the address of the control object, will return the
address of the current thread&rsquo;s instance of the TLS object.
</p>
<dl class="first-deftypevr">
<dt class="deftypevr" id="index-TARGET_005fEMUTLS_005fGET_005fADDRESS"><span class="category-def">Target Hook: </span><span><code class="def-type">const char *</code> <strong class="def-name">TARGET_EMUTLS_GET_ADDRESS</strong><a class="copiable-link" href="#index-TARGET_005fEMUTLS_005fGET_005fADDRESS"> &para;</a></span></dt>
<dd><p>Contains the name of the helper function that uses a TLS control
object to locate a TLS instance.  The default causes libgcc&rsquo;s
emulated TLS helper function to be used.
</p></dd></dl>

<dl class="first-deftypevr">
<dt class="deftypevr" id="index-TARGET_005fEMUTLS_005fREGISTER_005fCOMMON"><span class="category-def">Target Hook: </span><span><code class="def-type">const char *</code> <strong class="def-name">TARGET_EMUTLS_REGISTER_COMMON</strong><a class="copiable-link" href="#index-TARGET_005fEMUTLS_005fREGISTER_005fCOMMON"> &para;</a></span></dt>
<dd><p>Contains the name of the helper function that should be used at
program startup to register TLS objects that are implicitly
initialized to zero.  If this is <code class="code">NULL</code>, all TLS objects will
have explicit initializers.  The default causes libgcc&rsquo;s emulated TLS
registration function to be used.
</p></dd></dl>

<dl class="first-deftypevr">
<dt class="deftypevr" id="index-TARGET_005fEMUTLS_005fVAR_005fSECTION"><span class="category-def">Target Hook: </span><span><code class="def-type">const char *</code> <strong class="def-name">TARGET_EMUTLS_VAR_SECTION</strong><a class="copiable-link" href="#index-TARGET_005fEMUTLS_005fVAR_005fSECTION"> &para;</a></span></dt>
<dd><p>Contains the name of the section in which TLS control variables should
be placed.  The default of <code class="code">NULL</code> allows these to be placed in
any section.
</p></dd></dl>

<dl class="first-deftypevr">
<dt class="deftypevr" id="index-TARGET_005fEMUTLS_005fTMPL_005fSECTION"><span class="category-def">Target Hook: </span><span><code class="def-type">const char *</code> <strong class="def-name">TARGET_EMUTLS_TMPL_SECTION</strong><a class="copiable-link" href="#index-TARGET_005fEMUTLS_005fTMPL_005fSECTION"> &para;</a></span></dt>
<dd><p>Contains the name of the section in which TLS initializers should be
placed.  The default of <code class="code">NULL</code> allows these to be placed in any
section.
</p></dd></dl>

<dl class="first-deftypevr">
<dt class="deftypevr" id="index-TARGET_005fEMUTLS_005fVAR_005fPREFIX"><span class="category-def">Target Hook: </span><span><code class="def-type">const char *</code> <strong class="def-name">TARGET_EMUTLS_VAR_PREFIX</strong><a class="copiable-link" href="#index-TARGET_005fEMUTLS_005fVAR_005fPREFIX"> &para;</a></span></dt>
<dd><p>Contains the prefix to be prepended to TLS control variable names.
The default of <code class="code">NULL</code> uses a target-specific prefix.
</p></dd></dl>

<dl class="first-deftypevr">
<dt class="deftypevr" id="index-TARGET_005fEMUTLS_005fTMPL_005fPREFIX"><span class="category-def">Target Hook: </span><span><code class="def-type">const char *</code> <strong class="def-name">TARGET_EMUTLS_TMPL_PREFIX</strong><a class="copiable-link" href="#index-TARGET_005fEMUTLS_005fTMPL_005fPREFIX"> &para;</a></span></dt>
<dd><p>Contains the prefix to be prepended to TLS initializer objects.  The
default of <code class="code">NULL</code> uses a target-specific prefix.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-TARGET_005fEMUTLS_005fVAR_005fFIELDS"><span class="category-def">Target Hook: </span><span><code class="def-type">tree</code> <strong class="def-name">TARGET_EMUTLS_VAR_FIELDS</strong> <code class="def-code-arguments">(tree <var class="var">type</var>, tree *<var class="var">name</var>)</code><a class="copiable-link" href="#index-TARGET_005fEMUTLS_005fVAR_005fFIELDS"> &para;</a></span></dt>
<dd><p>Specifies a function that generates the FIELD_DECLs for a TLS control
object type.  <var class="var">type</var> is the RECORD_TYPE the fields are for and
<var class="var">name</var> should be filled with the structure tag, if the default of
<code class="code">__emutls_object</code> is unsuitable.  The default creates a type suitable
for libgcc&rsquo;s emulated TLS function.
</p></dd></dl>

<dl class="first-deftypefn">
<dt class="deftypefn" id="index-TARGET_005fEMUTLS_005fVAR_005fINIT"><span class="category-def">Target Hook: </span><span><code class="def-type">tree</code> <strong class="def-name">TARGET_EMUTLS_VAR_INIT</strong> <code class="def-code-arguments">(tree <var class="var">var</var>, tree <var class="var">decl</var>, tree <var class="var">tmpl_addr</var>)</code><a class="copiable-link" href="#index-TARGET_005fEMUTLS_005fVAR_005fINIT"> &para;</a></span></dt>
<dd><p>Specifies a function that generates the CONSTRUCTOR to initialize a
TLS control object.  <var class="var">var</var> is the TLS control object, <var class="var">decl</var>
is the TLS object and <var class="var">tmpl_addr</var> is the address of the
initializer.  The default initializes libgcc&rsquo;s emulated TLS control object.
</p></dd></dl>

<dl class="first-deftypevr">
<dt class="deftypevr" id="index-TARGET_005fEMUTLS_005fVAR_005fALIGN_005fFIXED"><span class="category-def">Target Hook: </span><span><code class="def-type">bool</code> <strong class="def-name">TARGET_EMUTLS_VAR_ALIGN_FIXED</strong><a class="copiable-link" href="#index-TARGET_005fEMUTLS_005fVAR_005fALIGN_005fFIXED"> &para;</a></span></dt>
<dd><p>Specifies whether the alignment of TLS control variable objects is
fixed and should not be increased as some backends may do to optimize
single objects.  The default is false.
</p></dd></dl>

<dl class="first-deftypevr">
<dt class="deftypevr" id="index-TARGET_005fEMUTLS_005fDEBUG_005fFORM_005fTLS_005fADDRESS"><span class="category-def">Target Hook: </span><span><code class="def-type">bool</code> <strong class="def-name">TARGET_EMUTLS_DEBUG_FORM_TLS_ADDRESS</strong><a class="copiable-link" href="#index-TARGET_005fEMUTLS_005fDEBUG_005fFORM_005fTLS_005fADDRESS"> &para;</a></span></dt>
<dd><p>Specifies whether a DWARF <code class="code">DW_OP_form_tls_address</code> location descriptor
may be used to describe emulated TLS control objects.
</p></dd></dl>

</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="MIPS-Coprocessors.html">Defining coprocessor specifics for MIPS targets.</a>, Previous: <a href="Target-Attributes.html">Defining target-specific uses of <code class="code">__attribute__</code></a>, Up: <a href="Target-Macros.html">Target Description Macros and Functions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
